package Filter;

import Exception.InvalidLevelException;
import logging.Level;
import logging.Record;

public class UserCustomFilter implements FilterStrategy {
//Clase ejemplo definida por el usuario
    private String msgFilter;
    private Level levelFilter;
    
    
    public UserCustomFilter (String msg, String level) {              
    	
        try{
        	this.msgFilter=msg;
            this.levelFilter =  Level.stringToLevel(level);
        }catch (InvalidLevelException e) {
        		e.printStackTrace();
        }       
    } 
    
    public Level getLevel() {
        return this.levelFilter;
    }

    public boolean apply(Record record) {           
            return ((record.getMessageFormatted().indexOf(this.msgFilter) >= 0)&&(this.getLevel().getPriority() >= record.getLevel().getPriority()));
    }   
    
}
